import { useRequest } from "@/hooks/useRequest";
import PhrasesAPI, { MerchantPhrasesVO } from "@/api/phrases";

export function usePhrases() {
  const queryParams = reactive<PageQuery>({
    pageNum: 1,
    pageSize: 10,
  });

  const phrasesList = ref<MerchantPhrasesVO[]>([]);
  const tableLoading = ref(false);
  watch(
    () => tableLoading.value,
    (val) => {
      console.log(val);
    }
  );
  onMounted(async () => {
    const { loading, res } = await useRequest(PhrasesAPI.page, queryParams);
    tableLoading.value = loading.value;
    phrasesList.value = res.value.list;
  });
  return {
    phrasesList,
    tableLoading,
  };
}
